package com.reggie.mapper;

import com.reggie.pojo.AddressBook;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressBookMapper {
    @Select("SELECT * FROM address_book WHERE user_id=#{userId} and is_deleted=0")
    List<AddressBook> findAll(Long userId);

    @Insert("INSERT INTO address_book(id, user_id, consignee, sex, phone, detail, label, is_default, create_time, update_time, create_user, update_user, is_deleted) " +
            "values (#{id}, #{userId}, #{consignee}, #{sex}, #{phone}, #{detail}, #{label}, 0, now(), now(), #{createUser}, #{updateUser}, 0)")
    Integer add(AddressBook addressBook);

    Integer edit(AddressBook addressBook);

    AddressBook find(Long id, Long userId, Integer isDefault);
}
